package com.vma.tools;

import java.io.Serializable;
import org.apache.commons.lang.RandomStringUtils;


/**
 * 短信验证码对象
 *
 * @author tangcc
 * @date 2016年3月15日
 */
public class SmsCode implements Serializable {

    /**
     *
     */
    private static final long serialVersionUID = 2737426050572895959L;

    /**
     * 发送验证码手机号码
     */
    private String mobile;

    /**
     * 短信验证码
     */
    private String smsCode;

    /**
     * 生成验证码系统时间戳
     */
    private long currentSystemTime;

    /**
     * 验证错误次数
     */
    private int errorTime = 0;

    /**
     * 使用手机号生成短信验证码对象
     *
     * @param mobile
     */
    public SmsCode(String mobile) {
        this.mobile = mobile;
        this.smsCode = generateSmsCode();
        this.currentSystemTime = System.currentTimeMillis();
        this.errorTime = 0;
    }

    private String generateSmsCode() {
        return  RandomStringUtils.random(6, false, true);
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getSmsCode() {
        return smsCode;
    }

    public void setSmsCode(String smsCode) {
        this.smsCode = smsCode;
    }

    public long getCurrentSystemTime() {
        return currentSystemTime;
    }

    public void setCurrentSystemTime(long currentSystemTime) {
        this.currentSystemTime = currentSystemTime;
    }

    public int getErrorTime() {
        return errorTime;
    }

    public void setErrorTime(int errorTime) {
        this.errorTime = errorTime;
    }
}
